home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!usenet
- From: yom@clark.net (yom)
- Newsgroups: comp.lang.c
- Subject: Re: changing strings via pointers
- Date: 1 Mar 1996 00:33:32 GMT
- Organization: home
- Message-ID: <4h5gks$83i@clarknet.clark.net>
- References: <1996Feb22.125436.25503@leeds.ac.uk> <4gls59$rct@clarknet.clark.net> <4h34jv$1t4@gryphon.phoenix.net>
- NNTP-Posting-Host: yom.clark.net
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.7
-
- On the surface, your suggestion of using strtok looks cleaner, but
- it comes at a *small* price. strtok function saves a pointer (4 or
- 8 bytes depending on your architecture) to the byte following the
- converted null byte. I know this isn't much, but it deserves some
- consideration especially if you're trying to produce a high performance
- software.
-
- Song (yom@clark.net)
-
-
- In article <4h34jv$1t4@gryphon.phoenix.net>, brucew@phoenix.net says...
- >
- >In comp.lang.c
- >yom@clark.net (yom) wrote:
- >
- >>You can use strchr string function to get the pointer to a newline
- >>character in your character array, and set what the pointer points
- >>to to NULL (0).
- >>
- >> char *b;
- >> if (b = strchr(buffer,'\n'))
- >> *b = 0;
- >
- >or you could simplify and use strtok(buffer, "\n");
- >
- >
- >Bruce D. Wedding Have Compiler, Will Travel!
- > Perspicacious Programming Performed Promptly
- >Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
- >
-
-